from collections import Counter

from ssq.notes_database import DataBase, config_dict

conn = DataBase(config_dict)

sql = """SELECT * FROM ssq WHERE id < 3"""
records = conn.query(sql)
for record in records:
    print(record)

conn.close()


class Statistic:
    def __init__(self):
        pass


class Duplication(Statistic):
    def __init__(self):
        self.counter = Counter
        self.dup_records = None
        self.conn = conn

    def get(self, records):
        self.dup_records = [key for key, value in self.counter(records).items() if value > 1]
        return self.dup_records
    def set(self):
        create_table = """CREATE TABLE IF NOT EXISTS duplication (
                            id INT NOT NULL ,
                            date DATE NOT NULL,
                            ident VARCHAR(10) NOT NULL,
                            red_1 INT NOT NULL,
                            red_2 INT NOT NULL,
                            red_3 INT NOT NULL,
                            red_4 INT NOT NULL,
                            red_5 INT NOT NULL,
                            red_6 INT NOT NULL,
                            blue INT NOT NULL,
                            times INT NOT NULL,
                            PRIMARY KEY (id)
                            );"""
        pass
